@mixin flex-max-width($max) {
  flex: 0 0 #{$max + '%'};
  max-width: #{$max + '%'};
}

.gl-responsive-table-row-layout {
  width: 100%;

  @include media-breakpoint-up(md) {
    display: flex;
    align-items: center;

    & > &:not(:first-child) {
      margin-top: $gl-padding;
    }
  }
}

.gl-responsive-table-row {
  @extend .gl-responsive-table-row-layout;
  margin-top: 10px;
  border: 1px solid $border-color;

  @include media-breakpoint-up(md) {
    margin: 0;
    padding: $gl-padding 0;
    border: 0;

    &:not(:last-child) {
      border-bottom: 1px solid $white-normal;
    }
  }
}

.gl-responsive-table-row-col-span {
  flex-wrap: wrap;
}

.table-section {
  white-space: nowrap;

  $section-widths: 10 15 20 25 30 40 50 100;
  @each $width in $section-widths {
    &.section-#{$width} {
      flex: 0 0 #{$width + '%'};

      @include media-breakpoint-up(md) {
        max-width: #{$width + '%'};
      }
    }
  }

  @include media-breakpoint-down(sm) {
    display: flex;
    align-self: stretch;
    padding: 10px;
    align-items: center;
    min-height: 62px;

    &:not(:first-child) {
      border-top: 1px solid $white-normal;
    }
  }

  &.section-wrap {
    white-space: normal;

    @include media-breakpoint-down(sm) {
      flex-wrap: wrap;
    }
  }

  &.section-align-top {
    align-self: flex-start;
  }
}

.table-button-footer {
  @include media-breakpoint-up(md) {
    text-align: right;
  }

  @include media-breakpoint-down(sm) {
    display: block;
    align-self: stretch;
    min-height: 0;
    background-color: $gray-normal;
    border-top: 1px solid $border-color;

    .table-action-buttons {
      display: flex;

      .btn {
        border-radius: 3px;
      }

      > .btn-group,
      > .external-url,
      > .btn {
        flex: 1 1 28px;

        &:not(:first-child) {
          margin-left: 5px;
        }

        &:not(:last-child) {
          margin-right: 5px;
        }
      }

      .dropdown-new {
        width: 100%;
      }

      .dropdown-menu {
        min-width: initial;
      }
    }
  }
}

.table-row-header {
  font-size: 13px;

  @include media-breakpoint-down(sm) {
    display: none;
  }
}

.table-mobile-header {
  @include flex-max-width(40);
  color: $gl-text-color-secondary;
  text-align: left;

  @include media-breakpoint-up(md) {
    display: none;
  }
}

.table-mobile-content {
  @include media-breakpoint-down(sm) {
    @include flex-max-width(60);
    text-align: right;
  }
}

.flex-truncate-parent {
  display: flex;
}

.flex-truncate-child {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  @include media-breakpoint-up(md) {
    flex: 0 0 90%;
  }

  .avatar {
    float: none;
    margin-right: 4px;
  }
}
